package com.gitee.aurora.server.controller;


import com.gitee.aurora.core.utils.ResultVO;
import com.gitee.aurora.core.utils.ResultVOUtils;
import com.gitee.aurora.server.service.PtcjConfigService;
import com.gitee.aurora.server.vo.DateListVo;
import com.gitee.aurora.server.vo.PtcjConfig;
import com.gitee.aurora.utils.PageParam;
import com.gitee.aurora.utils.Pagination;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/PtcjConfig")
@Api(value = "业务参数配置", tags = {"业务参数配置"})
public class PtcjConfigController {
    @Autowired
    private PtcjConfigService ptcjConfigService;

    @RequestMapping("/queryPtjc")
    @ApiOperation(value = "业务参数配置查询", notes = "业务参数配置查询")
    public ResultVO queryPtjc(@RequestBody DateListVo dateListVo){
        PtcjConfig ptcjConfig = dateListVo.getPtcjConfig();
        PageParam pageParam = dateListVo.getPageParam();
        if (pageParam == null || "".equals(pageParam.getPage()) || "".equals(pageParam.getLimit())){
            return ResultVOUtils.error("分页参数上送有误");
        }
        Pagination pagination = ptcjConfigService.queryPtjc(ptcjConfig, pageParam);
        return ResultVOUtils.success(pagination);
    }

    @RequestMapping("/updataPtcj")
    @ApiOperation(value = "业务参数配置更新", notes = "业务参数配置更新")
    public ResultVO updataPtcj(@RequestBody PtcjConfig ptcjConfig){
        return ptcjConfigService.updataPtcj(ptcjConfig);
    }

    @RequestMapping("/addPtcj")
    @ApiOperation(value = "业务参数配置添加", notes = "业务参数配置添加")
    public ResultVO addPtcj(@RequestBody PtcjConfig ptcjConfig){
        return ptcjConfigService.addPtcj(ptcjConfig);
    }

    @RequestMapping("/deletePtcj")
    @ApiOperation(value = "业务参数配置删除", notes = "业务参数配置删除")
    public ResultVO deletePtcj(@RequestBody List<PtcjConfig> ptcjConfig){
        return ptcjConfigService.deletePtcj(ptcjConfig);
    }
}
